<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div th:replace="~{commons/commons::head}"></div>

<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-row layui-col-space10">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend>CORS--跨域资源共享（Cross-origin resource sharing）</legend>
                    </fieldset>
                    <!--漏洞简介-->
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-eyedropper icon"></i>漏洞描述</div>
                            <div class="layui-card-body layui-text layadmin-text">
                                <p>同时满足同协议，同域名，同端口这三个条件，就是同源。</p>
                                <p>跨域问题是浏览器对于ajax请求的一种安全限制: 一个页面发起的ajax请求，默认情况下只能是与当前页域名相同的路径，这能有效的阻止跨站攻击。</p>
                                <p><a target="_blank" href="upload/cors.txt">POC</a></p>
                                <p><a target="_blank"
                                      href="https://blog.csdn.net/Be_insighted/article/details/119493419">跨域介绍</a></p>
                                <p><a target="_blank" href="https://www.cnblogs.com/gorillalee/p/14561896.html">跨域资源共享（CORS）漏洞详解</a>
                                </p>
                                <p><a target="_blank"
                                      href="https://www.cnblogs.com/Xy--1/p/13069099.html">CORS跨域漏洞学习</a></p>
                            </div>
                        </div>
                    </div>
                    <!--漏洞测试-->
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-hand-o-down icon"></i>漏洞测试</div>
                            <div class="layui-card-body layui-text layadmin-text">
                                <form class="layui-form" id="form" th:action="@{/home/cors}" method="get">

                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" id="submit" class="layui-btn" lay-submit=""
                                                    lay-filter="demo1">点击获取用户信息
                                            </button>
<!--                                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <!--执行结果-->
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-eyedropper icon"></i>测试结果</div>
                            <div class="layui-card-body layui-text layadmin-text">
                                <!--                                <pre th:text="${results}" style="color: red;font-size: 15px;"></pre>-->
                                <pre id="results" style="color: red;font-size: 15px;"></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:replace="~{commons/commons::script}">
</div>

<script>
    $("#submit").click(function () {
        // const origin = $("#origin").val();
        // if (origin.length === 0) {
        //     return;
        // }

        $.ajax({
            url: "[[@{/home/cors}]]",
            type: "get",
            // data: {origin: origin},
            success: function (result) {
                $("#results").empty();
                $("#results").append(he.escape(result));
            },
            error: function () {
                alert("请求发送失败！")
            },
        })
    })
</script>
</body>
</html>